package com.asset.salesforce.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


@SuppressWarnings("serial")
@Entity
@Table(name="roles")
//@Cache(usage= CacheConcurrencyStrategy.READ_WRITE)
public class Role implements Serializable{

    private Integer id;
    private String name;
    private String description;
    private Set<String> permissions;

    public Role() {
    }

    public Role(String name) {
        this.name = name;
    }
    
    /**
	 * @return the id
	 */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="roles_id_seq")
	@SequenceGenerator(name="roles_id_seq",sequenceName="roles_id_seq",allocationSize=1)
	public Integer getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	@Basic(optional=false)
    @Column(length=100)
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	@Basic(optional=false)
    @Column(length=255)
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the permissions
	 */
	 @ElementCollection
	 @CollectionTable(name = "roles_permissions",joinColumns = @JoinColumn(name="roles_id"))
	 @Column(name = "element")
	    //@JoinTable(name="roles_permissions")
//	    @Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
	public Set<String> getPermissions() {
		return permissions;
	}

	/**
	 * @param permissions the permissions to set
	 */
	public void setPermissions(Set<String> permissions) {
		this.permissions = permissions;
	}
}


